/*     */ package net.sourceforge.appgen.model;
/*     */ 
/*     */ import java.io.Serializable;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import net.sourceforge.appgen.converter.FirstCharacterUpperCaseConverter;
/*     */ import net.sourceforge.appgen.converter.StringConverter;
/*     */ import net.sourceforge.appgen.util.ConventionUtils;
import net.sourceforge.appgen.util.FileUtils;
/*     */ 
/*     */ public class Controller
/*     */   implements Serializable
/*     */ {
/*     */   private static final long serialVersionUID = 1L;
/*  35 */   private static final StringConverter firstCharacterUpperCaseConverter = new FirstCharacterUpperCaseConverter();
/*     */   private Entity entity;
/*     */ 
/*     */   public Controller(Entity entity)
/*     */   {
/*  40 */     this.entity = entity;
/*     */   }
/*     */ 
/*     */   public String getClassName() {
/*  44 */     return this.entity.getClassName() + "Controller";
/*     */   }
/*     */ 
/*     */   public String getFullPackageName() {
/*  48 */     return this.entity.getPackageName() + ".web.controller";
/*     */   }
/*     */ 	
			public String getRequestParameterSnippet() {
				StringBuffer buffer = new StringBuffer();
				for (Field field : this.entity.getPrimaryKeyFieldList()) {
					if (field.getFieldType().equals("char")) {
						buffer.append(field.getFieldType() + " " + field.getFieldName() + " = " + "'';" + FileUtils.ln());
					} else if ((field.isPrimitiveType()) || (String.class.getName().equals(field.getFieldType()))) {
						buffer.append(field.getSimpleFieldType()+" "+field.getFieldName()+",");
					} else {
						buffer.append(field.getSimpleFieldType() + " " + field.getFieldName() + " = " + "null;" + FileUtils.ln());
					}
				}
/* 123 */     return buffer.toString();
/*     */   }
/*     */ 
/*     */   public List<String> getImportClassNameList() {
/*  60 */     List list = new ArrayList();
/*     */ 
/*  64 */     list.add(this.entity.getFullPackageName() + "." + this.entity.getClassName());
/*     */ 
/*  66 */     Criteria criteria = new Criteria(this.entity);
				AdminContextInterceptor ad=new AdminContextInterceptor(this.entity.getPackageName());
/*  67 */     list.add(criteria.getFullPackageName() + "." + criteria.getClassName());
/*     */ 
/*  69 */     Service service = new Service(this.entity);
/*  70 */     list.add(service.getInterfaceFullPackageName() + "." + service.getInterfaceName());
/*     */ 
/*  72 */     list.add("java.util.List");
/*     */ 
/*  74 */     list.add("javax.servlet.http.HttpServletRequest");
/*  76 */     list.add("org.slf4j.Logger");
/*  77 */     list.add("org.slf4j.LoggerFactory");
				list.add("org.springframework.validation.BindingResult");
              list.add("javax.validation.Valid");
				list.add("org.springframework.beans.factory.annotation.Autowired");
				list.add("org.springframework.stereotype.Controller");
				list.add("org.springframework.ui.ModelMap");
				list.add("org.springframework.web.bind.annotation.RequestMapping");
				list.add(ad.getFullPackageName()+".ValidatorShow");
				
/*     */ 
/*  79 */     if (this.entity.getPrimaryKeyFieldList() != null) {
/*  80 */       for (Field field : this.entity.getPrimaryKeyFieldList()) {
/*  81 */         if ((!field.isCreate()) || (field.getFieldType().indexOf('.') <= 0) || 
/*  82 */           (field.getFieldType().equals("java.lang." + field.getSimpleFieldType())) || 
/*  83 */           (list.contains(field.getFieldType()))) continue;
/*  84 */         list.add(field.getFieldType());
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/*  91 */     return list;
/*     */   }
/*     */ 
/*     */   public List<String> getImportDeclarations() {
/*  95 */     List list = new ArrayList();
/*  96 */     list.addAll(getImportClassNameList());
/*     */ 
/*  98 */     return ConventionUtils.getImportDeclarations(list, getFullPackageName());
/*     */   }
/*     */ 
/*     */   public String getParseRequestParameterSnippet() {
/* 102 */     return getParseRequestParameterSnippet("\t\t");
/*     */   }
/*     */ 
/*     */   public String getParseRequestParameterSnippet(String indent) {
/* 106 */     StringBuffer buffer = new StringBuffer();
/*     */ 
/* 108 */     for (Field field : this.entity.getPrimaryKeyFieldList()) {
/* 109 */       if (field.getFieldType().equals("char")) {
/* 110 */         buffer.append(indent + "// FIXME: Entity generator." + FileUtils.ln());
/* 111 */         buffer.append(indent + field.getFieldType() + " " + field.getFieldName() + " = " + "'';" + FileUtils.ln());
/* 112 */       } else if ((field.isPrimitiveType()) || (String.class.getName().equals(field.getFieldType()))) {
/* 113 */         buffer.append(indent + field.getSimpleFieldType() + " " + field.getFieldName() + " = " + "ServletRequestUtils.getRequired" + firstCharacterUpperCaseConverter.convert(field.getSimpleFieldType()) + "Parameter(request, \"" + field.getFieldName() + "\");" + FileUtils.ln());
/*     */       } else {
/* 115 */         buffer.append(indent + "// FIXME: Entity generator." + FileUtils.ln());
/* 116 */         buffer.append(indent + field.getSimpleFieldType() + " " + field.getFieldName() + " = " + "null;" + FileUtils.ln());
/*     */       }
/*     */     }
/*     */ 
/* 120 */     return buffer.toString();
/*     */   }
/*     */ 
/*     */   public Entity getEntity() {
/* 124 */     return this.entity;
/*     */   }
/*     */ 
/*     */   public void setEntity(Entity entity) {
/* 128 */     this.entity = entity;
/*     */   }
/*     */ }

/* Location:           C:\Users\lzl6066\Downloads\net.sourceforge.appgen_1.2.0\plugins\net.sourceforge.appgen_1.2.0.201002031718\
 * Qualified Name:     net.sourceforge.appgen.model.Controller
 * JD-Core Version:    0.6.0
 */